<?php

namespace App\Http\Requests;

use App\Exceptions\BusinessException;
use App\Exceptions\CustomValidateException;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;

class UserRegister extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'acc_lg_name' => ['required', 'string', 'unique:acc'],
            'acc_lg_pwd' => ['required', 'string', 'min:8', 'max:20'],
            'user_age' => ['required', 'integer', 'between:1,200'],
            'acc_user_nick' => ['string'],
            'acc_user_icon' => ['string'],
            're_password' => ['required', 'string', 'same:acc_lg_pwd'],
        ];
    }

    protected function failedValidation(Validator $validator) {
        throw new CustomValidateException($validator);
    }
}
